<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算三个数字并从小到大排序</title>
</head>
<body>
    <script>
        //构建
        function sorting(n1,n2,n3){

            //注意转化
            var n1 = parseInt(prompt('请输入第一个数'));
            var n2 = parseInt(prompt('请输入第二个数'));
            var n3 = parseInt(prompt('请输入第三个数'));

            console.log(n1,n2,n3);

            //承接
            var first,second,third;

            if(n1>n2){
                //n1、n2互换
                first = n2;
                n2 = n1;
                n1 = first
            }
            if(n1>n3){
                //n1、n3互换
                second = n3;
                n3 = n1;
                n1 = second;
            }
            if(n2>n3){
                //n2、n3互换
                third = n3;
                n3 = n2;
                n2 = third;
                document.write(n1 + '<' + n2 + '<' + n3);
            }
            else{
                document.write(n2 + '<' + n1 + '<' + n3);
            }
        }

        //调用
        sorting(123,312,3);
    </script>
</body>
</html>